package com.snow.useviewdemo.lottie;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.airbnb.lottie.LottieAnimationView;
import com.airbnb.lottie.LottieDrawable;
import com.snow.useviewdemo.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * author : zyt
 * e-mail : 632105276@qq.com
 * date   : 2019-09-29
 * desc   :
 */
public class LottieAct extends Activity {
    @BindView(R.id.lottie_01)
    LottieAnimationView lottie01;
    @BindView(R.id.lottie_02)
    LottieAnimationView lottie02;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_lottie);
        ButterKnife.bind(this);
        //有使用imgs图就添加下面代码，没有就直接设置setAnimation("chinese.json")即可
        lottie01.setImageAssetsFolder("sds/images/");
        lottie01.setAnimation("sds/data.json");
        lottie01.setRepeatMode(LottieDrawable.REVERSE);//设置播放模式
//        lottie01.setRepeatCount(LottieDrawable.INFINITE);//设置重复次数

        lottie02.setImageAssetsFolder("sds/images/");
        lottie02.setAnimation("sds/data.json");
        lottie02.setRepeatMode(LottieDrawable.REVERSE);//设置播放模式
        lottie02.setProgress(0.6f);
    }

    @OnClick({R.id.btn_01, R.id.btn_02})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_01:
                lottie01.playAnimation();
                break;
            case R.id.btn_02:
                lottie02.playAnimation();
                break;
        }
    }
}
